home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11856 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: String Problem
  5. Date: Wed, 27 Mar 96 00:52:53 GMT
  6. Organization: none
  7. Distribution: world
  8. Message-ID: <827887973snz@genesis.demon.co.uk>
  9. References: <4j6l61$4no@B1FF.mindspring.com> <tsw-2503961721130001@cypher.3do.com>
  10. Reply-To: fred@genesis.demon.co.uk
  11. X-NNTP-Posting-Host: genesis.demon.co.uk
  12. X-Newsreader: Demon Internet Simple News v1.27
  13. X-Mail2News-Path: genesis.demon.co.uk
  14.  
  15. In article <tsw-2503961721130001@cypher.3do.com> tsw@3do.com "Tom Watson" writes:
  16.  
  17. >In article <4j6l61$4no@B1FF.mindspring.com>, vtipres@atl.mindspring.com wrote:
  18. >
  19. >> This is supposed to be a variation on sample code from a textbook.
  20. >> Can anyone tell me why NameCheck = 0 when I run the program?
  21. >> 
  22. >> /*
  23. >>    Testing character transactions.
  24. >> */
  25. >> 
  26. >> #include <stdio.h>
  27. >> #include <ctype.h>
  28. >> 
  29. >> int main()
  30. >> {
  31. >>    char Name[11] = "John";
  32. >
  33. >You have initialized a local variable to the text "John" (with a trailing
  34. >'nul' character.  After that (the first 5 locations in the array) the data
  35. >is undefined.
  36.  
  37. Nothing is undefined - you either initialise a whole object or none of it.
  38. Trailing elements/members are initialised to zero.
  39.  
  40. >The variable 'WhereName' is a pointer, and should not be printed with a
  41. >'%i' formatting specification.  Pointers can be different sizes than ints
  42. >(I use a compiler that this is the case!).  It should be printed with a
  43. >'%p' specification if you want to see what it is.
  44.  
  45. But make sure you cast the corresponding argument to void * if it doesn't
  46. already have that type.
  47.  
  48. -- 
  49. -----------------------------------------
  50. Lawrence Kirby | fred@genesis.demon.co.uk
  51. Wilts, England | 70734.126@compuserve.com
  52. -----------------------------------------
  53.